package com.xinan.system.curd;

import java.util.List;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * CurdMeta model.
 */
@TableBind(tableName = "curd_meta")
public class CurdMeta extends Model<CurdMeta> {
	public static final CurdMeta dao = new CurdMeta();

	public List<CurdMeta> findAll() {
		return find("select * from curd_meta order by id desc");
	}

	public CurdMeta findByTableName(String tableName) {
		return findFirst("select * from curd_meta where tablename=?", tableName);
	}

    public Page<CurdMeta> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from curd_meta";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        sqlExp += " order by id desc";
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }

	public String getId() {
		return get("id");
	}

	public String getTableName() {
		return get("tablename");
	}

	public String getQueryFields() {
		return get("queryfields");
	}

	public String getListFields() {
		return get("listfields");
	}
	
	public String getCuFields() {
		return get("cufields");
	}

	public String getRmk() {
		return get("rmk");
	}

	public String getOptName() {
		return get("optname");
	}

	public String getOptDate() {
		return get("optdate");
	}
}